;; syntax tokens

(define open-token #\()
(define close-token #\))
(define dot-token #\.)
(define quote-mark-token #\')
(define quasiquote-mark-token #\`)
(define unquote-mark-token #\,)

;; atoms

(define symbol-token
  `(seq (or ,alpha-class ,symbol-class)
        (star (or ,alpha-class ,symbol-class ,number-class))))

(define number-token
  `(or (plus ,number-class)
       (seq #\# #\b (plus (or #\0 #\1)))
       (seq #\# #\x (plus ,hex-class))))

(define boolean-token
  `(seq #\# (or #\t #\f)))

(define character-token
  `(seq #\# #\\
        (or ,number-class ,alpha-class ,symbol-class
            ,reserved-symbol-class)
        (star (or ,number-class ,alpha-class ,symbol-class))))

(define string-token
  `(seq #\"
        (star (or (or . ,(delete #\\ (delete #\" alphabet)))
                  (seq #\\ (or #\" #\\))))
        #\"))

;; whitespace

(define comment
  `(seq #\; (kleene (or . ,(delete #\newline alphabet)))
        #\newline))
(define whitespace-token
  `(plus (or #\space #\newline ,comment)))
